package com.api.organization.changepassword;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.test.context.ContextConfiguration;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;

import com.api.test.AbstractApiTest;
import com.zyncro.api.IOrganizationApiService;
import com.zyncro.api.exceptions.ZyncroApiException;

@ContextConfiguration(locations = { "classpath:/organization/organization-context.xml" })
public class ChangePasswordAdministrator extends AbstractApiTest {

	@Value("#{org_editOrganization[administrator].appId}")
	private String userId;

	@Value("#{org_editOrganization[administrator].password}")
	private String userPassword;

	@Value("#{org_editOrganization[toEdit].appId}")
	private String userToEditUrn;

	@BeforeMethod
	public void setUpVariables() {

		getApi().login(userId, userPassword);
	}

	@Test
	public synchronized void testChangePasswordA() throws ZyncroApiException {

		String newPassword = "123456";

		getApi().getService(IOrganizationApiService.class).changePassword(userToEditUrn, newPassword);

		getApi().login(userToEditUrn, newPassword);
	}

	@Test
	public synchronized void testChangePasswordB() throws ZyncroApiException {

		String newPassword = "abcdef";

		getApi().getService(IOrganizationApiService.class).changePassword(userToEditUrn, newPassword);

		getApi().login(userToEditUrn, newPassword);
	}
}
